<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="css/reset.css"/>
		<link rel="stylesheet" type="text/css" href="css/register.css"/>
	</head>
	<body>
		<form>
			<div id ="register">
				<div class="phone">
					<p>使用手机号注册</p>
					<p>
						<span>国家/地区</span><span>中国&nbsp;+86</span>
					</p>
					<input type="text" name="phoneNum" id="phoneNum" value="" placeholder="手机号" />
				</div>
				<div id = "password">
					<input type="password" name="pwd" id="pwd" value="" placeholder="密码" />
					<input type="password" name="" id="pwdConfirm" value="" placeholder="确认密码" />
					<p>至少 8 个字符，不能含有空格。字母、数字、符号至少包含2种。</p>
				</div>
				<div class="line"></div>
				<div class="button">
					<input type="button" name="" id="btn" value="完成" />
				</div>
			</div>
		</form>
		<script src="../jquery.min.js"></script>
		<script>
//			$("#btn").click(function(){
//				$.get("php/register.php",{phoneNum:$("#phoneNum").val(),pwd:$("#pwd").val()},function(res){
//					console.log(res);
//				});
//			});
			$("#btn").click(function(){
//				console.log($("#phoneNum").val(),$("#pwd").val());
				var reg_phone =$("#phoneNum").val();
				var reg_pwd = $("#pwd").val();
				if(reg_pwd != $("#pwdConfirm").val()){
					alert("密码不一致，请重新输入");
				}else{
					$.ajax({
							type : "get",
							url: "php/register.php",
							data: {
								phoneNum:$("#phoneNum").val(),
								pwd: $("#pwd").val()
							},
							success : function(res){
								if(res == "0"){
									alert("注册失败")
								}else if(res == "2"){
									alert("手机号已被注册")
								}else{
									alert("注册成功");
									localStorage.setItem("reg_phone",reg_phone);
									localStorage.setItem("reg_phone",reg_pwd);
									if(reg_pwd != $("#pwdConfirm").val()){
										alert("密码不一致，请重新输入");
									}
									location.href = "index.html";
								}
							}
						});
				}
				
			});
		</script>
	</body>
</html>
